Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get correct protocol when creating request. #966

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

zimonitrome
Copy link
Contributor

This replaces defaulting to http which is not always correct nor safe.

This feature was removed in an older commit (f69826f#diff-cf234a385fd7788d61976c078d5d093b2de418c259f1f7b3a15adb46ee1cedc3).

This commit re-implements said feature but with the standard of checking the "x-forwarded-proto" header or defaulting to "https". A standard which is already used in start-vercel:

let protocol = req.headers["x-forwarded-proto"] || "https";
let protocol = req.headers["x-forwarded-proto"] || "https";

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • infrastructure changes
  • Other... Please describe:

What is the current behavior?

The current behavior will incorrectly default some POST requests to use the HTTP protocol when sending information. This will trigger most browsers into warning the user about an unsecure exchange of information.

This will occur when the website headers does not include an origin header.

What is the new behavior?

The new behavior tries to interpret the correct protocol (HTTP/HTTPS) from the "x-forwarded-proto" header which is the de-facto standard header for identifying the protocol.

If an origin header does not exist, the request protocol will still be correctly set to the appropriate protocol.

This replaces defaulting to http which is not always correct nor safe.
@zimonitrome
Copy link
Contributor Author

This fixes issues I've been having for a very long time:
nextauthjs/next-auth#8155
OrJDev/solid-auth#8

@ryansolid ryansolid merged commit f89618d into solidjs:main Aug 7, 2023
11 of 13 checks passed
@ryansolid
Copy link
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants